// pages/yuyue/yuyue.js
import Toast from '@vant/weapp/toast/toast';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    morenColor: '#f0eff5',
    selectColor: 'skyblue',
    hotTag: [
      { tag: '家庭关系',active: false },
      { tag: '亲子关系',active: false },
      { tag: '婚恋感情',active: false },
      { tag: '生活问题',active: false },
      { tag: '个体咨询',active: false },
    ],
    selectedTags:'亲子关系',
    show:false,
    show1:false,
    minHour: 0,
    maxHour: 24,
    minDate: new Date(1990,1,1).getTime(),
    maxDate: new Date(2099, 12, 31).getTime(),
    currentDate: new Date().getTime(),
    currentChoose: '2024-07-07 00:00:00',
    message: '',
    array: ['国家一级心理咨询师', '国家二级心理咨询师', '国家三级心理咨询师'],
    index:0,
    objectArray:[
      {id:0,name:'国家一级心理咨询师'},
      {id:1,name:'国家二级心理咨询师'},
      {id:2,name:'国家三级心理咨询师'},
    ],
    level:"",
    field:"",
  },
  onCancel() {
    Toast('取消');
  },
  onChange(event) {
    const { picker, value, index } = event.detail;
    Toast(`当前值：${value}, 当前索引：${index}`);
  },
  itemSelected: function (e) {
    let index = e.currentTarget.dataset.index;
    let tag=this.data.hotTag[index].tag;
    let item = this.data.hotTag[index];
    item.active = !item.active;
    console.log("123",this.data.hotTag[index].tag)
    this.setData({
      field:this.data.hotTag[index].tag,
      hotTag: this.data.hotTag,
      selectedTags:this.data.hotTag[index].tag,
    });
  },
  toBack(){
    wx.navigateBack({
      url:"/pages/first/first"
    })
  },
enter(){
  wx.navigateTo({
    url:"/pages/yuyue/zixun/zixun?level="+this.data.level+"&field="+this.data.field
  })
},
  openPicker(){
    this.setData({show:true})
  },
  onConfirm(e) {
    this.setData({ show: false, currentChoose: this.formatDate(new Date(e.detail)) })
  },
  onCancel() {
    this.setData({ show: false })
  },
  formatDate(date) {
    let taskStartTime
    if (date.getMonth() < 9) {
      taskStartTime = date.getFullYear() + "-0" + (date.getMonth() + 1) + "-"
    } else {
      taskStartTime = date.getFullYear() + "-" + (date.getMonth() + 1) + "-"
    }
    if (date.getDate() < 10) {
      taskStartTime += "0" + date.getDate()
    } else {
      taskStartTime += date.getDate()
    }
    taskStartTime += " " + date.getHours() + ":" + date.getMinutes()
    this.setData({
      taskStartTime: taskStartTime,
    })
    return taskStartTime;
  },


  bindPickerChange: function(e) {
    console.log('picker发送选择改变，携带值为', this.data.array[e.detail.value])
    this.setData({
      level: this.data.array[e.detail.value],
      index: e.detail.value
    })
  },
  showPopup() {
    this.setData({ show: true,show1:false });
  },
  showPopup1() {
    this.setData({ show1: true,show:false });
  },
  onDisplay() {
    this.setData({ show: true });
  },
  onClose() {
    this.setData({ show: false });
  },
  onClose1(){
    this.setData({ show1: false });
  },
  cancel() {
    this.setData({ show: false });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.setNavigationBarTitle({
      title: '咨询预约',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})